﻿using DataAccess;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;

namespace Logic
{
    public class FS0202Logic
    {
        FS0202DataAccess fS0202DataAccess = new FS0202DataAccess();
        #region 检索
        public DataTable Search(string strRequirementNo,string strUserID)
        {
            return fS0202DataAccess.Search(strRequirementNo,strUserID);
        }
        #endregion

        #region 删除
        public void Delete(List<string> Items)
        {
            fS0202DataAccess.Delete(Items);
        }
        #endregion

        #region 生成订单
        public void CreateOrder(string strUserID,string strProjectNo)
        {
            string strMaxOrderNo = fS0202DataAccess.getMaxOrderNo();
            int iOrderNo = 1;
            if (string.IsNullOrEmpty(strMaxOrderNo))
            {
                iOrderNo = 1;
            }
            else
            {
                string tempOrder = strMaxOrderNo.Split('_')[strMaxOrderNo.Split('_').Length - 1];
                bool bRes = int.TryParse(tempOrder, out iOrderNo);
                if (bRes)
                {
                    iOrderNo++;
                }
                else
                {
                    iOrderNo = 1;
                }
            }
            string strOrderNo = strProjectNo + "_" + DateTime.Now.ToString("yyyy")+DateTime.Now.ToString("MM")+DateTime.Now.ToString("dd") +"_"+ iOrderNo;
            fS0202DataAccess.CreateOrder(strUserID, strProjectNo, strOrderNo);
        }
        #endregion

        #region 获取项目列表
        public DataTable getProjectList()
        {
            return fS0202DataAccess.getProjectList();
        }
        #endregion
    }
}
